





from pyecharts import options as opts
from pyecharts.charts import Radar


from pyecharts.globals import CurrentConfig

CurrentConfig.ONLINE_HOST="https://cdn.kesci.com/lib/pyecharts_assets/"





# 部门列表
departments = ['销售', '管理', '信息技术', '客服', '研发', '市场']


# 容忍的最大支出
max_cost_threshold = [6500, 16000, 30000, 38000, 52000, 25000]


# 预算分配
budget_allocation = [4300, 10000, 28000, 35000, 50000, 19000]


# 实际开销
actual_cost = [5000, 14000, 28000, 31000, 42000, 21000]





# 设置雷达图的边缘的最大值
schema = []
for dept, max_cost in zip(departments, max_cost_threshold):
    schema.append(opts.RadarIndicatorItem(name=dept, max_=max_cost))


schema


radar = (
    Radar()
    .add_schema(schema)
    .add("预算分配", [budget_allocation], linestyle_opts=opts.LineStyleOpts(color="#FF0000"))
    .add("实际开销", [actual_cost], linestyle_opts=opts.LineStyleOpts(color="#0000FF"))
    .set_series_opts(label_opts=opts.LabelOpts(is_show=False))
    .set_global_opts(
        #legend_opts=opts.LegendOpts(selected_mode="single"),
        title_opts=opts.TitleOpts(title="各部门预算与开销"),
    )
)

radar.render_notebook()



